package 矩阵问题;

import java.util.Scanner;

public class 矩阵转置 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[][] a = new int[n][m];
        // 输入a
        for (int i = 0; i < n; i++) {
            for (int i1 = 0; i1 < m; i1++) {
                a[i][i1] = scanner.nextInt();
            }
        }
        // 输入b
        int[][]b = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                b[i][j] = a[j][i];
            }
        }
        // 输出b
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(b[i][j]+" ");
            }
            System.out.println();
        }

    }
}
